<%-- 
    Document   : AniDatos
    Created on : 23-oct-2013, 17:55:12
    Author     : pavel
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="com.ptr.controladores.conexionsqlserver"%>
<%@page import="java.sql.*"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="Expires" content="0"/>
        <meta http-equiv="Pragma" content="no-cache"/>
        <script language="JavaScript">
        function BuscaDatos(sel) {
            if (sel.value=="6"){
                 divC = document.getElementById("datos");
                 divC.style.display = "";
            }else{

                 divC = document.getElementById("datos");
                 divC.style.display="none";
            }
           }
        </script>
        <script type="text/javascript">
         {
         if(history.forward(1))
         location.replace(history.forward(1))
         }
         </script>
        <title>Sistema de Registros Civiles</title>
    </head>
    <% conexionsqlserver base=new conexionsqlserver();
        Connection c=null;ResultSet rs=null; Statement st=null;
        String genero=null;
        String dep=null;
        String prov=null;
        String dist=null;
        String otro=null;
        String nubi=null;
    %>
    <body style="background-color: #f9f9f9 ">
        <form action="${pageContext.request.contextPath}/ConsultasActasImagen" method="POST">   
            <div>
                <table border="0" align="center" width="80%" style="border: 2px solid #1b3150">                
    <tr><td>
          <div>
            <table align="center" border="0" style="background-color: #597498">
                <tr>
                    <td>
                        <table border="0" width="100%"><tr>
                                <td style="background-color: #597498;width: 30%"><div><label style="font-size: 1.5em; font-weight: bold; color: white">DATOS GENERALES</label></div></td>
                                <td style="width: 13%"><label style="color: white; font-size: 0.8em; font-weight: bold; font-family: Arial">Seleccione Acta</label></td>
                                <td>    <select name="Actas" style="width: 15em; height: 2em; 
                                            font-family: Arial; font-weight: bold; background-color: #d4e0f2;
                                            border: 1px solid #f8e3b9; size: 0.2em; border-radius: 5px 5px 5px 5px"">
                                            <option selected value="0">Seleccione tipo de Acta</option>
                                            <option value="1">Nacimiento</option>
                                            <option value="2">Matrimonio</option>
                                            <option value="3">Defuncion</option>
                                    </select>
                                 </td>
                                 <td>
                                    <label style=" color: white; font-size: 0.8em; font-weight: bold; font-family: Arial">Seleccione tipo de Busqueda</label>
                                  </td> 
                                  <td style="width: 13%">
                                    <div>
                                        <select name="TipoBus" onchange="BuscaDatos(this)" style="width: 15em; height: 2em; 
                                            font-family: Arial; font-weight: bold; background-color: #d4e0f2;
                                            border: 1px solid #f8e3b9; size: 0.2em; border-radius: 5px 5px 5px 5px"">
                                        <option selected value="0">Seleccione tipo de Acta</option>
                                        <option value="4">Nro Acta</option>
                                        <option value="5">Nro CUI</option>
                                        <option value="6">Datos Personales</option>
                                        </select>
                                    </div>
                                </td>
                            </tr></table>
                </tr>
                <tr>
                    <td colspan="3">
                        <div id="datos" style="display:none;">
                            <table border="0" align="center" style="color:#f8fcff; font-family: Arial; font-size: 0.8em " >
                            <td><label>Primer Apellido</label>
                                <input type="text" name="p_ape" value="" style="border-radius: 5px 5px 5px 5px ;height: 25px;border: 1px solid #64a3f9;background-color: #f8feff"></td>
                            <td><label>Segundo Apellido</label>
                                <input type="text" name="s_ape" value="" style="border-radius: 5px 5px 5px 5px ;height: 25px;border: 1px solid #64a3f9;background-color: #f8feff"></td>
                           <td><label>Prenombre(S)</label>
                                <input type="text" name="p_nom" value="" style="border-radius: 5px 5px 5px 5px ;height: 25px;border: 1px solid #64a3f9;background-color: #f8feff"></td>
                            </table>
                        </div>
                   </td>
                </tr>
                <tr><td>
                        <fieldset style="border: 1px solid #f1c363;background-color: #fffde7;width: 72em">
                            <legend style="border: 1px solid #f1c363; background-color: #fffde7; color: #b27244">Datos Principales</legend>
                    <table border="0" align="center" width="100%">
                        <tr>
                            <td><label/>Cui</td>
                            <td><%String cui=(String)request.getAttribute("cui"); if(cui!=null){%>
                                <input type="text" name="cui_acta" value="<%=cui%>" style="font-weight: bold;border: 1px solid #f1c363;background-color: #fdeecd;font-family: Arial">
                                <%}else{%>
                                <input type="text" name="cui_acta" value="" style="font-weight: bold;border: 1px solid #f1c363;background-color: #fdeecd;font-family: Arial"></td>
                                <%}%>
                            <td><label/>Nro Acta</td>
                            <td>
                                <%String nacta=(String)request.getAttribute("nacta");if(nacta!=null){%>
                                <input type="text" name="nro_acta" value="<%=nacta%>" style="font-weight: bold;border: 1px solid #f1c363;background-color: #fdeecd;font-family: Arial">
                                <%}else{%>
                                <input type="text" name="nro_acta" value="" style="font-weight: bold;border: 1px solid #f1c363;background-color: #fdeecd;font-family: Arial"></td>
                                <%}%>
                            <td><label/>Nro Libro</td>
                            <td><%String nlibro=(String)request.getAttribute("nlibro");if(nlibro!=null){%>
                                <input type="text" name="nro_libro" value="<%=nlibro%>" readonly="true"  style="font-weight: bold;border: 1px solid #f1c363;background-color: #fdeecd;font-family: Arial">
                                <%}else{%>
                                <input type="text" name="nro_libro" value="" readonly="true"  style="font-weight: bold;border: 1px solid #f1c363;background-color: #fdeecd;font-family: Arial"></td>
                                <%}%>
                                </tr>
                        <tr>
                            <td style="width: 10em "> <label style="text-align: right "/>Ciudadano (A)</td>
                            <td><%String datos=(String)request.getAttribute("datos");if(datos!=null){%>
                                <input type="text" value="<%=datos%>" name="DatosPer" readonly="true" style="width: 25em;font-weight: bold;border: 1px solid #f1c363;background-color: #fdeecd;font-family: Arial">
                                <%}else{%>
                                <input type="text" value="" name="DatosPer" readonly="true" style="width: 25em;font-weight: bold;border: 1px solid #f1c363;background-color: #fdeecd;font-family: Arial"></td>
                                <%}%>
                            <td><label/>Edad</td>
                            <td><input type="text" name="EdadP" style="border: 1px solid #f1c363;background-color: #fdeecd; width: 5em"></td>
                            <td><label/>Genero</td>
                            <td><%String g1=(String)request.getAttribute("g1");
                            if(g1!=null){%>
                                <input type="text" name="GenerP" value="<%=g1%>" readonly="true"  style="font-weight: bold;border: 1px solid #f1c363;background-color: #fdeecd;font-family: Arial">
                            <%}else{%>
                                <input type="text" name="GenerP" value="" readonly="true"  style="font-weight: bold;border: 1px solid #f1c363;background-color: #fdeecd;font-family: Arial"></td>
                            <%}%>
                        </tr>
                    </table>
                </fieldset>
                    </td></tr>
            </table>
            </div>
        </td>
        </tr>
            <!--Datos de la Persona!-->
<tr>            
    <td>
            <div>
            <table align="center" border="0" width="100%">
                <tr><td width="70%">
                        <fieldset style="border: 1px solid #5ba0ff;background-color: #f5f9ff;width: 50em">
                            <legend style="border: 1px solid #5ba0ff; background-color: #f5f9ff; color: #85aabb">Lugar de Domicilio</legend>
                    <table border="0" align="center" width="100%">
                        <tr><%String ubidom=(String)request.getAttribute("ubidom");
                        
                        if(ubidom!=null)
                        {
                            dep=ubidom.substring(0, 2);
                            prov=ubidom.substring(2, 4);
                            dist=ubidom.substring(4, 6);
                            otro=ubidom.substring(6, 8);
                        }
                        String query=null;
                        try
                        {
                            base.conectar(); c=base.getconection();
                            st=c.createStatement();
                            query="select (u.nom_ubigeo_dep +' / '+ u.nom_ubigeo_prov+' / '";
                            query=query+"+u.nom_ubigeo_dist +' / '+ u.nom_ubigeo_dist) as nom_ubigeo from TB_UBIGEO u";
                            query=query+" where idubigeo='"+ubidom+"'";
                            rs=st.executeQuery(query);
                            if(rs.next())
                            {
                                nubi=rs.getString(1);
                            }
                        }catch(SQLException ex)    
                        {
                            System.out.println("Existe erron en la busqueda de Ubigeo :" + ex.getMessage());
                        }
                      if(ubidom!=null){%>
                            <td><input type="text" readonly="true"  name="DepP" value="<%=dep%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                            <td><input type="text" readonly="true"  name="ProvP" value="<%=prov%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                            <td><input type="text" readonly="true"  name="DistP" value="<%=dist%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                            <td><input type="text" readonly="true" name="OtroP" value="<%=otro%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                            <td><input type="text" readonly="true"  name="nomubiP" value="<%=nubi%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 30em; height: 2em "></td>
                        <%}else{%>                            
                            <td><input type="text" readonly="true"  name="DepP" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                            <td><input type="text" readonly="true"  name="ProvP" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                            <td><input type="text" readonly="true"  name="DistP" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                            <td><input type="text" readonly="true" name="OtroP" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                            <td><input type="text" readonly="true"  name="nomubiP" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 30em; height: 2em "></td>
                        <%}%>
                            <td width="30%">Cod. Postal</td>
                            <td width="30%"><input type="text" readonly="true" value="" name="CpostalP" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 9em; height: 2em "></td>
                        </tr>
                    </table>
                </fieldset>
                </td>
                <td  rowspan="4">
                        <fieldset style="border: 1px solid #5ba0ff;background-color: #f5f9ff;width: 20em">
                            <legend style="border: 1px solid #5ba0ff; background-color: #f5f9ff; color: #85aabb">IMAGEN ACTA</legend>
                    <table border="0" align="center" width="10%">
                        <tr>
                            <td><%String rnac=(String)request.getAttribute("rnac");
                                if(rnac!=null){%>
                                <object width="300px" height="400em">
                                    <embed src="<%=rnac%>" readonly="true"  width="300px" height="400em" alt="<%=rnac%>">
                                </object><%}else{%>
                                <object width="300px" height="400em">
                                    <embed src="/RegCivil/imagenes/noacta.jpg" readonly="true"  width="300px" height="400em" alt="<%=rnac%>">
                                </object><%}%>
                            </td>
                        </tr>
                    </table>
                </fieldset>
                </td>                        
                </tr>
                <tr>
                    <td>
                        <fieldset style="border: 1px solid #5ba0ff;background-color: #f5f9ff;width: 50em">
                            <legend style="border: 1px solid #5ba0ff; background-color: #f5f9ff; color: #85aabb">Direcci&oacute;n</legend>
                    <table border="0" align="center" width="100%">
                        <tr>
                            <td><%String cdir=(String)request.getAttribute("cdir");
                            String query2=null;
                            String ndir=null;
                            try
                            {
                                base.conectar();c=base.getconection();
                                st=c.createStatement();
                                query2="select * from TB_TIPO_DIRECCION";
                                query2=query2+" where COD_DIR='"+cdir+"'";
                                rs=st.executeQuery(query2);
                                if(rs.next())
                                {ndir=rs.getString(2);}
                            }
                            catch(SQLException dir )
                            {System.out.println("Error en la busqueda de Direccion:" + dir.getMessage()); }
                            %>
                            <%if(ndir!=null){%>
                            <input type="text" readonly="true"  name="dir" value="<%=ndir%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 5em; height: 2em "><br>
                            <%}else{%>
                            <input type="text" readonly="true"  name="" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 5em; height: 2em "><br>
                            <%}%>
                                <label style="font-size:0.7em; color:#898b92; font-weight: bold">Jr/Av/Cl</label></td>
                            <td><%String dper=(String)request.getAttribute("dper");
                            if(dper!=null){%>
                                <input type="text" readonly="true"  name="DirPer" value="<%=dper%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 30em; height: 2em ">
                                <%}else{%>
                                <input type="text" readonly="true"  name="" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 30em; height: 2em ">
                                <%}%>
                                <br><label style="font-size:0.7em; color:#898b92; font-weight: bold">Nombre /Jr/Av/Cl</label></td>
                            
                            <td><%String nrodir=(String)request.getAttribute("nrodir");
                            if(nrodir!=null){%>
                                <input type="text" readonly="true" name="nrodir" value="<%=nrodir%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 4em; height: 2em ">
                                <%}else{%>
                                <input type="text" readonly="true" name="" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 4em; height: 2em ">
                                <%}%>
                            <br><label style="font-size:0.7em; color:#898b92; font-weight: bold">Nro</label></td>
                        </tr>
                    </table>
               </tr>
               <tr>
                    <td width="70%">
                        <fieldset style="border: 1px solid #5ba0ff;background-color: #f5f9ff;width: 50em">
                            <legend style="border: 1px solid #5ba0ff; background-color: #f5f9ff; color: #85aabb">Lugar de Nacimiento y Fecha</legend>
                            <table border="0" align="center" width="100%">
                                <tr><%String ubinac=(String)request.getAttribute("ubinac");
                                String depPN=(String)request.getAttribute("depPN");
                                String ProvPN=(String)request.getAttribute("ProvPN");
                                String DistPN=(String)request.getAttribute("DistPN");
                                String OtroPN=(String)request.getAttribute("OtroPN");
                                String nubinac=(String)request.getAttribute("nubinac");
                                if(ubinac!=null){%>
                                    <td><input type="text" readonly="true" name="DepPN" value="<%=depPN%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                                    <td><input type="text" readonly="true" name="ProvPN" value="<%=ProvPN%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                                    <td><input type="text" readonly="true" name="DistPN" value="<%=DistPN%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                                    <td><input type="text" readonly="true" name="OtroPN" value="<%=OtroPN%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                                    <td><input type="text" readonly="true" name="nomubinac" value="<%=nubinac%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 25em; height: 2em "></td>
                                    <td><label/>Fecha de Nac.</td><%String fnac=(String)request.getAttribute("fnac");if(fnac!=null){%>
                                    <td><input type="text" name="OtroPN" value="<%=fnac%>" readonly="true" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 10em; height: 2em "></td>
                                    <%}else{%>
                                    <td><input type="text" readonly="true" name="DepPN" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                                    <td><input type="text" readonly="true" name="ProvPN" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                                    <td><input type="text" readonly="true" name="DistPN" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                                    <td><input type="text" readonly="true" name="OtroPN" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 2em; height: 2em "></td>
                                    <td><input type="text" readonly="true" name="nomubinac" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 25em; height: 2em "></td>
                                    <td><label/>Fecha de Nac.</td>
                                    <td><input type="text" name="OtroPN" value="" readonly="true" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 10em; height: 2em "></td>
                                    <%}%>
                                    <%}else{%>
                                    <td><input type="text" name="OtroPN" value="" readonly="true" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 10em; height: 2em "></td>
                                    <%}%>
                                </tr>
                            </table>
                        </fieldset>
                    </td>
                </tr>
                <!-- otros datos!--> 
                <tr>
                    <td width="70%">
                        <fieldset style="border: 1px solid #5ba0ff;background-color: #f5f9ff;width: 50em">
                            <legend style="border: 1px solid #5ba0ff; background-color: #f5f9ff; color: #85aabb">
                                Otros Datos</legend>
                            <table border="0" align="center" width="100%">
                                <tr>
                                    <td width="10%" ><label/>Estado Civil</td>
                                    <%String ecivil=(String)request.getAttribute("civil");
                                    if(ecivil!=null){%>
                                    <td><input type="text" readonly="true" value="<%=ecivil%>" name="ProvPN" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 15em; height: 2em "></td>
                                    <%}else{%>
                                    <td><input type="text" readonly="true" value="" name="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 15em; height: 2em "></td>
                                    <%}%>
                                    <td width="20%" >
                                        <button type="submit" name="btn2" value="DatosNAc"style='width:10.0em; heigth:8em; background-color: #eeeeee;border: 1px solid #9cafff;border-radius: 7px 7px 7px 7px;'><img src='/RegCivil/imagenes/find.png'>Buscar</button>
                                    </td>
                                </tr>
                                <tr>
                                    <td>G&eacute;nero</td>
                                    <%if(g1!=null){%>
                                    <td><input type="text" readonly="true" value="<%=g1%>" name="OtroPN" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 15em; height: 2em "></td>
                                    <%}else{%>
                                    <td><input type="text" readonly="true" value="" name="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 15em; height: 2em "></td>
                                    <%}%>
                                    <td width="20%" >
                                        <button type="reset" style='width:10.0em; heigth:8em; background-color: #eeeeee;border: 1px solid #9cafff;border-radius: 7px 7px 7px 7px;'><img src='/RegCivil/imagenes/note_edit.png'>Limpiar</button>
                                    </td>
                                </tr>
                                <tr>
                                    <td><label>Estado</label></td>
                                    <%String estpers=(String)request.getAttribute("estpers"); 
                                    String query4=null, e=null;
                                    
                                    try
                                    {
                                        base.conectar();c=base.getconection();
                                        st=c.createStatement();
                                        query4="select * from TB_ESTADO_PERSONA";
                                        query4=query4+" where COD_ESTADO_PERS='"+estpers+"'";
                                        rs=st.executeQuery(query4);
                                        if(rs.next())
                                        {e=rs.getString(2);}
                                    }
                                    catch(SQLException est)
                                    {System.out.println("Error en la busqueda de Tipo de Estado Persona: " + est.getMessage());}
                                    if(e!=null){%>
                                    <td><input type="text" readonly="true" name="estado" value="<%=e%>" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 15em; height: 2em "></td>
                                    <%}else{%>
                                    <td><input type="text" readonly="true" name="" value="" style="border: 1px solid #5ba0ff;background-color: #f9f9f9;width: 15em; height: 2em "></td>
                                    <%}%>
                                    <td width="20%" >
                                       <button type=button onclick="JavaScript:location.href='/RegCivil/main.jsp'" style='width:10.0em; heigth:8em; background-color: #eeeeee;border: 1px solid #9cafff;border-radius: 7px 7px 7px 7px;'><img src='/RegCivil/imagenes/return.png'>Retornar</button>
                                    </td>
                                </tr>
                            </table>
                        </fieldset>
                    </td>
                </tr>
            </table>
      </td>
  </tr>
</table>
            </div>
        </form>
    </body>
</html>
